package com.oa.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.oa.bean.User;
import com.oa.service.LoginService;
import com.oa.service.impl.LoginServiceImpl;

@Controller
@RequestMapping("/login")
public class LoginController {
	
	@Autowired
	private LoginServiceImpl loginService;

	@RequestMapping("/log")
	public String log(HttpServletRequest request,Model model){
		String username=request.getParameter("username");
		String pwd=request.getParameter("pwd");
		System.out.println(username+","+pwd);
		User user=new User();
		user.setUsername(username);
		user.setUpass(pwd);
		User user2=loginService.login(user);
		System.out.println(user2);
		
		model.addAttribute("user", user2);
		
		return "../index";
	}
}
